#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
int main(){
	int id=fork();
	if(id == 0) {  //子进程
        int cnt = 5;
        while(cnt--) {
            printf("子进程, pid:%d, ppid:%d, cnt:%d\n", getpid(), getppid(), cnt);
            sleep(1);
        }
        exit(1);
      }
     else {  //父进程
        sleep(10);
        int status = 0;
        pid_t ret = waitpid(id,&status,0);
		printf("exit signal:%d,  exit code:%d\n", (status & 0x7f), (status >> 8 & 0xff));
	 }
	 return 0;
}
